package com.cfl.ticketmodule.service.impl;

import java.util.ArrayList;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cfl.model.Ticket;
import com.cfl.ticketmodule.dao.TicketMapper;
import com.cfl.ticketmodule.service.TicketService;

@Service
public class TicketServiceImpl implements TicketService{

	@Autowired
	private TicketMapper ticketMapper;
	
	public ArrayList<Ticket> getAll() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}
	
	public void addTicket(Ticket ticket) throws Exception {
		try {
			if(ticket == null)
			{
				return;
			}
			ticket.setTid(UUID.randomUUID().toString());
			ticketMapper.insert(ticket);
		} catch (Exception e) {
			throw e;
		}
	}
	
	public ArrayList<Ticket> findMyTickets(String uid,int page) throws Exception {
		try {
			return ticketMapper.selectByAll(uid,page*20, 20);
		} catch (Exception e) {
			throw e;
		}
	}
}
